﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace SuuntoWebsite.Events._201205
{
    public partial class Selection : System.Web.UI.Page
    {
        string sqlcon = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString_Event"].ConnectionString;
        protected string userName = string.Empty;
        protected string userId = string.Empty;
        protected string rewrite = System.Configuration.ConfigurationManager.AppSettings["rewriteType"];
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SetValue())
            {
                BindProductsList();
            }
            else
            {
                Response.Redirect("./registration" + rewrite);
            }
        }
        protected bool SetValue()
        {
            bool flag=true;
            userId = Public.Cookie.UserId;
            userName = Public.Cookie.UserName;
            if (userId.Equals("0") || userName.Equals("0"))
                flag = false;
            return flag;
        }
        protected void BindProductsList()
        {
            DataTable dt = new Bll.EventForSuunto.BLLSuunto_Products().SuuntoProductsList(sqlcon);
            if (dt.Rows.Count > 0)
            {
                ProductsList.DataSource = dt;
                ProductsList.DataBind();
                dt.Dispose();
            }

        }
        protected string FormatMoney(object obj)
        {
            return string.Format("{0:N}", Convert.ToDouble(obj));
        }
        protected string FormatCount(object obj)
        {
            if (Convert.ToInt32(obj) > 0)
                return obj.ToString();
            else
                return "缺货";
        }
    }
}
